import { defineStore } from "pinia";
import { computed, ref } from "vue";
import ACCESS_ENUM from "@/access/accessEnum";
import { UserControllerService } from "../../generated";
import router from "@/router";

export const useUserStore = defineStore("useUserStore", () => {
  const loginUser = ref({
    userName: "NOTLOGIN",
    userAccount: "",
    userPassword: "",
    userRole: ACCESS_ENUM.USER_NOT_LOGIN,
  });

  async function getLoginUser() {
    const res = await UserControllerService.getLoginUserUsingGet();
    console.log("res", res);

    if (res.code === 0) {
      loginUser.value.userName = "laoyu";
      loginUser.value.userRole = <string>res.data?.userRole;
    }
  }

  return { loginUser, getLoginUser };
});
